//
//  LuckyMonthView.m
//  Koizora
//
//  Created by dlios on 15-6-9.
//  Copyright (c) 2015年 CupCat. All rights reserved.
//

#import "LuckyMonthView.h"

@implementation LuckyMonthView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self) {
        
        self.label1 = [[UILabel alloc] init];
        _label1.text = @"恋情";
        [self addSubview: _label1];
        
        NSLog(@"%@",_lianqing.text);
        self.lianqing = [[UILabel alloc] init];
        self.lianqing.numberOfLines = 0;
//        self.lianqing.backgroundColor = [UIColor redColor];
        [self addSubview:self.lianqing];

        self.label2 = [[UILabel alloc] init];
        _label2.text = @"工作";
        [self addSubview: _label2];
        
        self.gongzuo = [[UILabel alloc] init];
//        self.gongzuo.backgroundColor = [UIColor redColor];
        self.gongzuo.numberOfLines = 0;
        [self addSubview:self.gongzuo];
        
        self.label3 = [[UILabel alloc] init];
        _label3.text = @"求职";
        [self addSubview:_label3];
        
        self.qiuzhi = [[UILabel alloc] init];
//        self.qiuzhi.backgroundColor = [UIColor redColor];
        self.qiuzhi.numberOfLines = 0;

        [self addSubview:self.qiuzhi];
        
        self.label4 = [[UILabel alloc] init];
        _label4.text = @"财运";
        [self addSubview:_label4];
        
        self.caiyun = [[UILabel alloc] init];
//        self.caiyun.backgroundColor = [UIColor redColor];
        _caiyun.numberOfLines = 0;
        [self addSubview: self.caiyun];
        
        self.label5 = [[UILabel alloc] init];
        _label5.text = @"健康";
//        _label5.backgroundColor = [UIColor yellowColor];
        [self addSubview:_label5];

        self.jiankang = [[UILabel alloc] init];
        _jiankang.numberOfLines = 0;
        [self addSubview:_jiankang];
        
        
        self.xz = [[UILabel alloc] init];
        [self addSubview:_xz];
        
        
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _label1.frame = CGRectMake(0, 0, self.frame.size.width , 30);
    
    CGFloat f = [[self class] heightWithText:_lianqing.text];
    self.lianqing.frame =CGRectMake(0, _label1.frame.size.height + _label1.frame.origin.y, self.frame.size.width, f);
    
    
    _label2.frame = CGRectMake(0,_lianqing.frame.origin.y + _lianqing.frame.size.height , self.frame.size.width , 30);
    
    CGFloat ff = [[self class] heightWithText:_gongzuo.text];
    self.gongzuo.frame = CGRectMake(0, _label2.frame.origin.y + _label2.frame.size.height,self.frame.size.width, ff);
    
     _label3.frame = CGRectMake(0, _gongzuo.frame.origin.y + _gongzuo.frame.size.height, self.frame.size.width , 30);
    
    CGFloat fff = [[self class] heightWithText:_qiuzhi.text];
    self.qiuzhi.frame = CGRectMake(0, _label3.frame.origin.y + _label3.frame.size.height, _label3.frame.size.width, fff);
    
    _label4.frame = CGRectMake(0, _qiuzhi.frame.size.height + _qiuzhi.frame.origin.y, self.frame.size.width, 30);
    
    CGFloat ffff = [[self class] heightWithText:_caiyun.text];
    self.caiyun.frame = CGRectMake(0, _label4.frame.size.height + _label4.frame.origin.y, _label4.frame.size.width, ffff);
    NSLog(@"0.0%f",ffff);
    
    _label5.frame = CGRectMake(0, _caiyun.frame.size.height + _caiyun.frame.origin.y, self.frame.size.width, 30);
    NSLog(@"%f",_caiyun.frame.size.height + _caiyun.frame.origin.y);
    
    CGFloat fffff = [[self class]heightWithText:_jiankang.text];
    _jiankang.frame = CGRectMake(0, _label5.frame.size.height + _label5.frame.origin.y, self.frame.size.width, fffff);
    

}

// label自适应高度
+(CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
